public class P38 {
	public static void main(String[] args) {
		int max = 0;
		
		for (int n = 1; true; n++) {
			//System.out.println(n);
			if (String.valueOf(n).length() == 5) {
				break;
			}

			StringBuffer result = new StringBuffer();
			for (int p = 1; true; p++) {
				result.append(n * p);
				if (String.valueOf(result).length() > 9) {
					break;
				}

				if (result.length() == 9) {
					boolean idPandigit = true;

					for (int i = 1; i <= 9; i++) {
						if (result.indexOf(String.valueOf(i)) < 0) {
							idPandigit = false;
							break;
						}
					}

					if (idPandigit) {
						System.out.println(">>>" + result.toString());
						int x = Integer.parseInt(result.toString());
						if (max < x) {
							max = x;
						}
					}
				}
			}
		}
		System.out.println();
		System.out.println(max);
	}
}
